package com.qf.smartdevice.mapper;

import com.qf.smartdevice.pojo.Devices;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface DevicesMapper {
    @Select("select * from devices")
    List<Devices> findAllDevices();


    int devicesById(@Param("ids") int[] ids);

    @Insert("insert into devices value(null,#{devicesuuid},#{devicename},#{addtime},#{address},#{areaid},#{direction},#{num},#{status},#{lastconnecttime},#{categoryid})")
    int insertDevices(Devices devices);

    int updateByIdDevice(Devices devices);

    @Update("update devices set status=#{status} where devicesuuid=#{devicesuuid} ")
    int updateStatusByUUID(@Param("devicesuuid") String devicesuuid, @Param("status") String status);

    @Select("SELECT categoryid FROM devices WHERE devicesuuid =#{devicesuuid}")
    Long getCategoryIdByUUID(String uuid);

}
